package com.hk.admin.spring.security;

import com.hk.admin.common.model.system.UserModel;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * <br>
 * <b>功能：</b>自定义security用户<br>
 * <b>作者：</b>Pan.ShiJu<br>
 * <b>日期：</b>2017/10/4 23:27<br>
 */
@Data
public class UserDetail extends User implements Serializable {

    private Long id;        // 用户名（账号）

    private UserModel user;

    private List<String> pathInvariable;    // 普通uri，没有可变参数
    private List<String[]> pathVariable;    // 含有参数的rui

    public UserDetail(UserModel user, Collection<? extends GrantedAuthority> authorities) {
        super(user.getPhoneNumber(), user.getPassword(), authorities);
        this.id = user.getId();
        this.user = user;
    }

    public UserDetail(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
    }
}
